package org.jeecg.modules.oauth.xkwoauth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.oauth.xkwoauth.entity.SysThirdOauthRelationship;
import org.jeecg.modules.oauth.xkwoauth.mapper.SysThirdOauthRelationshipMapper;
import org.jeecg.modules.oauth.xkwoauth.service.ISysThirdOauthRelationshipService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: sys_third_oauth_relationship
 * @author: baochangrong
 * @Date:   2022-08-18
 * @Version: V1.0
 */
@Service
public class SysThirdOauthRelationshipServiceImpl extends ServiceImpl<SysThirdOauthRelationshipMapper, SysThirdOauthRelationship> implements ISysThirdOauthRelationshipService {

    @Override
    public SysThirdOauthRelationship getByUserId(String sysUserId) {
        LambdaQueryWrapper<SysThirdOauthRelationship> sysThirdOauthRelationshipQueryWrapper = new LambdaQueryWrapper<SysThirdOauthRelationship>();
        sysThirdOauthRelationshipQueryWrapper.eq(SysThirdOauthRelationship::getSysUserId,sysUserId);
        return getOne(sysThirdOauthRelationshipQueryWrapper);
    }
    @Override
    public SysThirdOauthRelationship getByOpenId(String openId){
        LambdaQueryWrapper<SysThirdOauthRelationship> sysThirdOauthRelationshipQueryWrapper = new LambdaQueryWrapper<SysThirdOauthRelationship>();
        sysThirdOauthRelationshipQueryWrapper.eq(SysThirdOauthRelationship::getThirdOpenid,openId);
        return getOne(sysThirdOauthRelationshipQueryWrapper);
    }
    @Override
    public List<SysThirdOauthRelationship> getListByTenantId(String tenantId) {
        LambdaQueryWrapper<SysThirdOauthRelationship> sysThirdOauthRelationshipQueryWrapper = new LambdaQueryWrapper<SysThirdOauthRelationship>();
        sysThirdOauthRelationshipQueryWrapper.eq(SysThirdOauthRelationship::getTenantId,tenantId);
        return list(sysThirdOauthRelationshipQueryWrapper);
    }
}
